home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
yase.arc
/
CASE.ASM
next >
Wrap
Assembly Source File
|
1986-12-13
|
2KB
|
49 lines
******************************************************************
* COPYRIGHT (C) 1986 by Donald Krantz and James Stanley
* - Note: This is a real, live, actual, registered copyright,
* and should be treated as such. This source code is from
* the book "68000 Assembly Language", Krantz and Stanley,
* Addison-Wesley Publishing Company, Reading, MA, 1986.
*
* Permission granted by the authors for non-commercial use
* in programs released to the public domain, as long as this
* copyright notice remains attached and visible.
*
****************************************************************
* CASE - Case statement executor
*
* ENTRY: A0 contains address of case table
* D0 contains case selector value
*
* Case Table:
* dc.w number of valid options
* dc.w first match value
* dc.l address of first case arm
* dc.w second match value
* dc.l address of second case arm
* . . .
* dc.w n'th match value
* dc.l address of n'th case arm
* dc.l default (no match) arm
*
* EXIT: A0 is undefined.
* D0 retains case selector value.
*
.xdef case
case:
move.l d1,-(a7) * save caller's D1
move.w (a0)+,d1 * get case value count
subq.w #1,d1 * adjust count value
loop:
cmp.w (a0)+,d0 * Check against match value
beq done * found it.
addq.l #4,a0 * move past useless case arm
dbra d1,loop * try again
done:
move.l (a7)+,d1 * restore caller's d1
move.l (a0),a0 * get jump address
jmp (A0) * go execute case arm.
*
*** Note: return from case arm is to statement following ********
*** the call to this routine ************************************